#ifndef MEALDATAREADER_H
#define MEALDATAREADER_H

#include <QObject>
#include <QFile>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>

class MealDataReader : public QObject
{
    Q_OBJECT
    class DataReadStatus{
    public:
        DataReadStatus() {reset();}
        void reset() {name = false;id = false;group = false;amount = false;calorie = false;protein = false;ch = false;fat = false;}
        bool isCompete() const {return (name && id /*&& group*/ && amount && calorie && protein && ch && fat);}
        bool name, id, group, amount, calorie, protein, ch, fat;
    };

public:
    struct MealData {
        int id;
        int group;
        QString name;
        QString amount;
        double energia;
        double feherje;
        double szenhidrat;
        double fat;
    };


    MealDataReader(QSqlQuery *q, QSqlDatabase *db, QObject *parent = 0);
    void readFile(QString fn, bool flush = true);
    QString convertName(QString inStr);
private:
    QList<MealData> collectedData;
    QSqlQuery *m_query;
    QSqlDatabase *m_db;
signals:

public slots:

};

#endif // MEALDATAREADER_H
